package com.rain.cy.business.model.dto;

import cn.hutool.core.bean.BeanUtil;
import com.rain.cy.business.model.entity.CommonProcessEntity;
import com.rain.cy.business.model.entity.UserProcessStatusEntity;
import lombok.Data;
import org.assertj.core.util.Lists;

import java.util.List;

/**
 * @author yu_chen
 * @since 2021/10/16 11:28
 */
@Data
public class UserProcessStatusDTO {


    /**
     * 患者当前的流程ID
     */
    private String processId;

    /**
     * 流程名称
     */
    private String processName;

    /**
     * 状态 1 完成 0 或者为空表示未完成
     */
    private Integer processStatus;

    private List<UserProcessStatusDTO> children;


    public static UserProcessStatusDTO from(UserProcessStatusEntity userProcessStatusEntity) {
        UserProcessStatusDTO userProcessStatusDTO = BeanUtil.copyProperties(userProcessStatusEntity, UserProcessStatusDTO.class);
        userProcessStatusDTO.setChildren(Lists.newArrayList());
        return userProcessStatusDTO;
    }

    public static UserProcessStatusDTO from(CommonProcessEntity commonProcessEntity) {
        UserProcessStatusDTO userProcessStatusDTO = new UserProcessStatusDTO();
        userProcessStatusDTO.setProcessId(commonProcessEntity.getId());
        userProcessStatusDTO.setProcessName(commonProcessEntity.getProcessName());
        userProcessStatusDTO.setChildren(Lists.newArrayList());
        return userProcessStatusDTO;
    }
}
